<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
	</head>
	<body>
		<script>
			//有序的数据集合
			
			//直接创建数组
			var arr = [1,2,3,4,5];
			
			//通过构造函数创建
			
			var arr_new = new Array(5);
			
			// 索引值
			// search(index)
			console.log( arr[0] );
			
			//push()
			
			//unshift() 从头部增加数据
			
			arr[9] = 8;
			console.log(arr);
			
			//concat 会返回新数组
			var arr2 = [10,11,12];
				
			var arr3 = arr.concat(arr2);
			
			
			//删除
			var arr4 = ['h','e','l','l','o','!'];
			
			console.log(arr4.join('').toString().trim());
			
			//pop 队尾删除
			
			//shift() 增加队头
			
			//splice() 改变原数组	
			
			arr4.splice(2,0,...'jps'); //插入l
			
//			arr4.splice(2,1,'B,b,c');//l替换B
			
//			arr4.splice(2,1);//删除l
			
			console.log('splice: ');
			console.log( arr4 );
			
			var goal = arr4.join('').toString().search(/l/gi);
			arr4.splice(goal,1);
		
		
	//slice(开始位置（从0开始）, 结束位置(index))   截取   创建新数组
			var new_arr = arr4.slice(1,4);
			console.log(new_arr);
			
	//数组也有indexOf()、lastIndexOf()
			
			
	//includes  返回boolean 判断所选字符存不存在
			var arr4 = ['h','e','l','l','o','!',5];
			var arr5 = arr4.includes('e');
			var arr6 = arr4.includes(5);
			console.log(arr5);
			console.log(arr6);
		</script>
	</body>
</html>
